package fag.core.game.test.pong;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import fag.core.geometry.Rectangle2D;
import fag.core.geometry.Vector2D;
import fag.core.model.Animation;
import fag.core.model.Frame;
import fag.core.model.Model;
import fag.core.model.SerializableImage;
import fag.core.model.Sprite;

@SuppressWarnings("serial")
public class RacketModel extends Model {
	
	public RacketModel(String name) {
		loadRacketModel(name);
	}
	
	private void loadRacketModel(String name) {
		Animation a = new Animation(name);
		Frame f1 = new Frame(1);
		BufferedImage bufferedImage = null;
		try {
			bufferedImage = ImageIO.read(new File(System.getProperty("user.dir")+"/src/imgs/pong/" + name + ".png"));
		} catch (IOException e) {
			e.printStackTrace();
		}
		Sprite s1 = new Sprite(new SerializableImage(bufferedImage),new Vector2D());
		Rectangle2D hitbox1 = new Rectangle2D(0, 0, s1.getWidth(), s1.getHeight());
		f1.setHitbox(hitbox1);
		f1.setSprite(s1);
		f1.updateBounds();
		a.addFrame(f1);
		getListAnimation().add(a);
	}
}
